<?xml version="1.0" encoding="iso-8859-1"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  xmlns:s="http://www.codeplex.com/MSSqlSchemaDoc">

  <xsl:import href="Columns.xsl"/>
  <xsl:import href="Triggers.xsl"/>
  <xsl:import href="Indexes.xsl"/>
  <xsl:import href="ForeignKeys.xsl"/>

  <xsl:param name="DocumentationFile"/>

  <xsl:template match="/s:Table">
    <html>
      <head>
        <title>Table: <xsl:value-of select="@Schema"/>.<xsl:value-of select="@Name"/></title>
        <link rel="stylesheet" type="text/css" href="../main.css"/>
      </head>
      <body>
        <table width="100%">
          <tr>
            <td width="50%" class="descriptionHeader right">Table: </td>
            <td class="objectName">
              <xsl:value-of select="@Schema"/>.<xsl:value-of select="@Name"/>
            </td>
          </tr>
          <tr>
            <td colspan="2" class="blank"></td>
          </tr>
          <tr>
            <td colspan="2" class="documentationHeader center">
              Description:
            </td>
          </tr>
          <tr>
            <td colspan="2" class="documentation center">
              <pre>
                <xsl:value-of select="document($DocumentationFile)/s:TableDocumentation/s:Documentation"/>
                <xsl:value-of select="document($DocumentationFile)/s:ViewDocumentation/s:Documentation"/>
              </pre>
            </td>
          </tr>

          <!-- Columns -->
          <xsl:apply-templates select="s:Columns"/>

          <tr>
            <td colspan="2" class="blank"></td>
          </tr>

          <!-- Triggers -->
          <xsl:apply-templates select="s:Triggers"/>

          <tr>
            <td colspan="2" class="blank"></td>
          </tr>
          
          <!-- Indexes -->
          <xsl:apply-templates select="s:Indexes"/>

          <tr>
            <td colspan="2" class="blank"></td>
          </tr>
          
          <!-- Foreign Keys -->
          <xsl:apply-templates select="s:ForeignKeys"/>

        </table>
      </body>
    </html>
  </xsl:template>

</xsl:stylesheet>